package com.turbo.cloud.bpm.web.webservice;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.turbo.cloud.bpm.web.logic.FlwInfoLogic;
import com.turbo.cloud.bpm.web.model.custom.CustomFlwInfoDo;
import com.turbo.cloud.bpm.web.model.custom.CustomFlwInfoQo;
import com.turbo.cloud.bpm.web.model.custom.CustomFlwInfoVo;
import com.turbo.cloud.core.api.R;
import com.turbo.cloud.core.api.Result;
import com.turbo.cloud.core.base.PageQuery;
import com.turbo.cloud.core.validated.InsertValidated;
import com.turbo.cloud.core.validated.UpdateValidated;
import jakarta.validation.constraints.NotBlank;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 流程信息表 前端控制器
 * </p>
 *
 * @author zhangluning
 */
@RequiredArgsConstructor
@RestController
public class CustomFlwInfoController {

    final FlwInfoLogic flwInfoLogic;

    /**
     * 查询流程信息分页列表
     *
     * @param pageQuery 分页查询
     */
    @PostMapping(name = "查询流程信息分页列表", value = "/webservice/flwInfo/queryFlwInfoPage")
    public Result<Page<CustomFlwInfoVo>> queryFlwInfoPage(@RequestBody PageQuery<CustomFlwInfoQo> pageQuery) {
        Page<CustomFlwInfoVo> result = flwInfoLogic.queryFlwInfoPage(pageQuery);
        return R.result(result);
    }

    /**
     * 查询流程信息，根据流程ID
     *
     * @param id 流程信息ID
     */
    @GetMapping(name = "查询流程信息，根据流程ID", value = "/webservice/flwInfo/queryFlwInfoById")
    public Result<CustomFlwInfoVo> queryFlwInfoById(@NotBlank(message = "流程信息ID不能为空") String id) {
        CustomFlwInfoVo result = flwInfoLogic.queryFlwInfoById(id);
        return R.result(result);
    }

    /**
     * 新增流程信息
     *
     * @param customFlwInfoDo 实体
     */
    @PostMapping(name = "新增流程信息", value = "/webservice/flwInfo/createFlwInfo")
    public Result<Boolean> createFlwInfo(@RequestBody @Validated(InsertValidated.class) CustomFlwInfoDo customFlwInfoDo) {
        boolean result = flwInfoLogic.createFlwInfo(customFlwInfoDo);
        return R.result(result);
    }

    /**
     * 修改流程信息
     *
     * @param customFlwInfoDo 实体
     */
    @PostMapping(name = "修改流程信息", value = "/webservice/flwInfo/modifyFlwInfo")
    public Result<Boolean> modifyFlwInfo(@RequestBody @Validated(UpdateValidated.class) CustomFlwInfoDo customFlwInfoDo) {
        boolean result = flwInfoLogic.modifyFlwInfo(customFlwInfoDo);
        return R.result(result);
    }

    /**
     * 删除流程信息
     *
     * @param id 流程信息ID
     */
    @GetMapping(name = "删除流程信息", value = "/webservice/flwInfo/removeFlwInfoById")
    public Result<Boolean> removeFlwInfoById(@NotBlank(message = "流程信息ID不能为空") String id) {
        boolean result = flwInfoLogic.removeFlwInfoById(id);
        return R.result(result);
    }

    /**
     * 开启、关闭流程信息有效状态
     *
     * @param id 流程信息ID
     */
    @GetMapping(name = "开启、关闭流程信息有效状态", value = "/webservice/flwInfo/enabledFlwInfoStateById")
    public Result<Boolean> enabledFlwInfoStateById(@RequestParam @NotBlank(message = "流程信息ID不能为空") String id) {
        boolean result = flwInfoLogic.enabledFlwInfoStateById(id);
        return R.result(result);
    }
}
